/**
 * Created by IntelliJ IDEA.
 * User: Bezdelnick
 * Date: 17.06.13
 * Time: 4:43
 * To change this template use File | Settings | File Templates.
 */
package {
import flash.events.Event;
import flash.events.MouseEvent;

public class DragableMaterialPoint extends MaterialPoint {
    public function DragableMaterialPoint() {
        if (stage) onAddedToStage();
        else this.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
    }

    private function onAddedToStage(evet:Event = null):void {
        this.addEventListener(MouseEvent.MOUSE_DOWN, dragStart);
        this.addEventListener(MouseEvent.MOUSE_UP, dragStop);
        this.addEventListener(MouseEvent.MOUSE_OUT, dragStop);
    }

    public function dragStart(event:Event):void {
        this.startDrag();
    }

    public function dragStop(event:Event):void {
        this.stopDrag();
    }
}
}
